package com.kawa.service.impl;

import com.kawa.mapper.UsersMapper;
import com.kawa.service.UsersService;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.kawa.entity.po.table.UserTableDef.USER;

/**
 * @Author: KAIyo
 * @Date: 2025/7/24 10:31
 * @Version: v1.0.0
 * @Description: TODO
 **/
@Service
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;


    /**
     * 查询手机是否被注册
     *
     * @param mobile 手机号
     * @param countryCode 国家代码
     * @return
     */
    @Override
    public boolean checkPhone(String mobile, String countryCode) {

        QueryWrapper queryWrapper = QueryWrapper.create()
                .select()
                .from("user")
                .where(USER.MOBILE.eq(mobile))
                .and(USER.COUNTRY_CODE.eq(countryCode));


        return usersMapper.selectOneByQuery(queryWrapper) != null;
    }
}
